InStrB Function

Returns the byte position of the first occurrence of a String inside another String. The first character is numbered 1.

Syntax

result = InStrB( [start], source, find )

result = stringVariable.InStrB( [start], find )


Parameters

start (Optional)

Integer

Optional byte position from which to begin searching the source string. One is the default if omitted.

source

String

Required. String expression being searched.

find

String

Required. String expression being sought.



Notes

If the find string is not found within the source string, 0 (zero) is returned. InStrB is case-sensitive; it treats source as a series of raw bytes. It should be used instead of InStr when the string represents binary data or when your application will run in a one-byte character set (such as the US system) and you want case-sensitivity.

If you need to find the character position of the find string within the source string, use the InStr function.


Examples

This example uses the InStrB function to locate a String within another string.

Dim first As Integer
first = InStrB ("This is a test", "T")
//returns 1
first = InStrB("This is a test", "t")      
//returns 11
first = InStrB("This is a test", "is")    
//returns 3
first = InStrB(4, "This is a test", "is")
//returns 6
first = InStrB("This is a test", "tester")
//returns 0
first = InStrB("This Is a test", "Is")
//returns 6

See Also

AscB, ChrB, InStr, LeftB, LenB, NthFieldB, MidB, RightB, SplitB, StrComp functions.